package ca.polymtl.rubikcube.CameraActivity;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;

public class OverlayView extends View {
	final private static String LOG_TAG = OverlayView.class.getSimpleName();

	Paint ticTacToPaint;

	public OverlayView(Context context, AttributeSet attrs) {
		super(context, attrs);
		Log.d("CUBE", "OverlayView ctor C");

		ticTacToPaint = new Paint();
		Log.d(LOG_TAG, "Width = " + this.getWidth() + ", Height = " + this.getHeight());
	}

	@Override
	protected void onDraw(Canvas canvas) {
		super.onDraw(canvas);

		Log.d(LOG_TAG, "onDraw");

		int centreW, centreH;
		centreW = this.getWidth() / 2;
		centreH = this.getHeight() / 2;

		int w = (int) (getWidth() * 0.9);

		int gauche = centreW - w / 2;
		int droite = centreW + w / 2;

		int haut = centreH - w / 2;
		int bas = centreH + w / 2;

		ticTacToPaint.setColor(Color.WHITE);

		ticTacToPaint.setAlpha(200);
		ticTacToPaint.setStrokeWidth(5f);
		ticTacToPaint.setStyle(Paint.Style.STROKE);

		// Carré
		canvas.drawRect(gauche, haut, droite, bas, ticTacToPaint);

		// Lignes
		canvas.drawLine(centreW - w / 6, centreH - w / 2, centreW - w / 6, centreH + w / 2, ticTacToPaint);
		canvas.drawLine(centreW + w / 6, centreH - w / 2, centreW + w / 6, centreH + w / 2, ticTacToPaint);
		canvas.drawLine(centreW - w / 2, centreH - w / 6, centreW + w / 2, centreH - w / 6, ticTacToPaint);
		canvas.drawLine(centreW - w / 2, centreH + w / 6, centreW + w / 2, centreH + w / 6, ticTacToPaint);
	}

}
